package com.share.lottery.activity.fab;

import java.io.File;

import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.EditText;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.HttpUtils;
import com.lidroid.xutils.bitmap.BitmapDisplayConfig;
import com.lidroid.xutils.bitmap.callback.BitmapLoadCallBack;
import com.lidroid.xutils.bitmap.callback.BitmapLoadFrom;
import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.RequestParams;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;
import com.lidroid.xutils.http.client.HttpRequest.HttpMethod;
import com.share.lottery.R;
import com.share.lottery.base.BaseActivity;
import com.share.lottery.http.ConstansController;
import com.share.lottery.utils.StringUtil;

/**
 * @author py
 *发表页面
 */
public class FabiaoActivtiy extends BaseActivity {
	private TextView tvGk;//是否公开
	private EditText edBt;//标题
	private EditText edDetal;//详细
	private String imgPath;
	private BitmapUtils bitmapUtils;
	private ImageView imgShow;
	private TextView tvFabio;
	protected void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.fab);
		if (bitmapUtils == null) {
			bitmapUtils = new BitmapUtils(this);
		}
		init();
	}
	public void findView() {
		tvFabio = (TextView) findViewById(R.id.tv_sure);
		tvGk = (TextView) findViewById(R.id.tv_gk);
		edBt = (EditText) findViewById(R.id.ed_bt);
		edDetal = (EditText) findViewById(R.id.ed_detal);
		imgShow = (ImageView) findViewById(R.id.img_zp);
	}

	public void getData() {
		imgPath = getIntent().getStringExtra("path");
		ConstansController.getInstance().upLoadFileForYky(new Handler(), imgPath);

	
	}


	private TextView titleTv;
	public void initTitle() {
		ImageButton titleLeftImg = (ImageButton) findViewById(R.id.title_left_img);
		TextView titleRightImg = (TextView) findViewById(R.id.title_right_tv);
		titleTv = (TextView) findViewById(R.id.title_tv_center);

		titleLeftImg.setImageResource(R.drawable.back);
		titleTv.setText("发表");
		titleRightImg.setVisibility(View.GONE);
		titleLeftImg.setOnClickListener(new OnClickListener() {

			public void onClick(View arg0) {
				finish();

			}
		});
	}

	public void setData() {
		bitmapUtils.display(imgShow, imgPath, new BitmapLoadCallBack<View>() {


			public void onLoadCompleted(View container, String uri,
					Bitmap bitmap, BitmapDisplayConfig config,
					BitmapLoadFrom from) {
				((ImageView)container).setImageBitmap(bitmap);

			}


			public void onLoadFailed(View container, String uri,
					Drawable drawable) {
				((ImageView)container).setImageResource(R.drawable.login_bgg);

			}
		});

	}
	private String bt;//标题
	private String detal;//详情
	private void faBiao(){
		bt = edBt.getText().toString();
		detal = edDetal.getText().toString();
		if (StringUtil.isNullOrEmpty(bt)) {
			showShortToast("请输入标题");
			return;
		}
		if (StringUtil.isNullOrEmpty(detal)) {
			showShortToast("请输入详情");
			return;
		}
		if (StringUtil.isNullOrEmpty(imgPath)) {
			showShortToast("请先选择图片");
			return;
		}



	}
	public void setonCliker() {

		tvFabio.setOnClickListener(new OnClickListener() {

			public void onClick(View view) {

				
			}
		});
	}

}
